package com.glut.vo;

import java.util.*;

/**
 * @Author:shenly
 * @date:2020/05/02
 * @Description: 临时试卷表
 */
public class TempExam {

    private Long eId;
    private Integer totalScore;
    /**
     * 试卷的难度系数
     */
    private Double difficultyLevel;
    /**
     * 试卷中所有的知识点id----知识点用set存储--
     */
    private Set<String> knowPoints;
    /**
     * 各种题型的题目数量
     */
    private List<Map<String,Integer>> qtList;
    /**
     * 题目
     */
    private List<SdfsQuestions> questionList;
    /**
     * 适应度
     */
    private Double adapterDegree;
    /**
     * 知识点覆盖率
     */
    private Double kpCoverage;

    public TempExam() {
        this.questionList=new ArrayList<SdfsQuestions>();
        this.adapterDegree=0.0;
        this.kpCoverage=0.0;
    }

    public TempExam(Long eId, int totalScore, double difficultyLevel, Set<String> knowPoints,
                    List<Map<String, Integer>> qtList) {
        this.eId = eId;
        this.totalScore = totalScore;
        this.difficultyLevel = difficultyLevel;
        this.knowPoints = knowPoints;
        this.qtList = qtList;
        this.questionList=new ArrayList<SdfsQuestions>();
        this.adapterDegree=0.0;
        this.kpCoverage=0.0;
    }


    public TempExam(Long eId, int totalScore, double difficultyLevel, Set<String> knowPoints,
                    List<Map<String, Integer>> qtList, List<SdfsQuestions> questionList, double adapterDegree, double kpCoverage) {
        this.eId = eId;
        this.totalScore = totalScore;
        this.difficultyLevel = difficultyLevel;
        this.knowPoints = knowPoints;
        this.qtList = qtList;
        this.questionList = questionList;
        this.adapterDegree = adapterDegree;
        this.kpCoverage = kpCoverage;
    }

    public Long geteId() {
        return eId;
    }

    public void seteId(Long eId) {
        this.eId = eId;
    }

    public Integer getTotalScore() {
        return totalScore;
    }

    /**
     * 设置现有试卷总分
     * @param
     */
    public void setTotalScore1() {
        Integer qtId;
        int sum=0;
        for(SdfsQuestions questions:questionList) {
            qtId=Integer.parseInt(questions.getQuestionType().toString());
            //for(Map<String, List<SdfsQuestions>> map:qtList) {
                if (qtId==1) {
                    sum+=2;
                }else if (qtId==2){
                    sum+=2;
                }else if (qtId==3){
                    sum+=3;

                }else if (qtId==4||qtId==5){
                    sum+=5;
                }
            //}
        }
        this.totalScore=sum;
    }

    public Double getDifficultyLevel() {
        return difficultyLevel;
    }

    /**
     * 设置试卷的难度系数(所有题目分数*难度系数/总分)
     * @param
     */
    public void setDifficultyLevel1() {
        double difficult=0.0;
        Long qtId;
        for(SdfsQuestions questions:questionList) {
            qtId=Long.parseLong(questions.getQuestionType().toString());
            if (qtId==1) {
                difficult+=2*questions.getDifficulty();
            }else if (qtId==2){
                difficult+=2*questions.getDifficulty();
            }else if (qtId==3){
                difficult+=3*questions.getDifficulty();

            }else if (qtId==4||qtId==5){
                difficult+=5*questions.getDifficulty();
            }

        }
        this.difficultyLevel = difficult/totalScore;
    }

    public Set<String> getKnowPoints() {
        return knowPoints;
    }

    /**
     * 设置试卷的知识点
     * @param
     */
    public void setKnowPoints1() {
        Set<String> knowPoints=new HashSet<>();
        for(SdfsQuestions questions:questionList) {
            String secKld = questions.getSecKld();
            String[] s = secKld.split(",");
            for (String s1:s){
                knowPoints.add(s1);
            }
        }
        this.knowPoints=knowPoints;
    }

    public List<Map<String, Integer>> getQtList() {
        return qtList;
    }

    public void setQtList(List<Map<String, Integer>> qtList) {
        this.qtList = qtList;
    }

    public List<SdfsQuestions> getQuestionList() {
        return questionList;
    }

    public void setQuestionList(List<SdfsQuestions> questionList) {
        this.questionList = questionList;
    }

    public Double getAdapterDegree() {
        return adapterDegree;
    }

    public void setAdapterDegree(Double adapterDegree) {
        this.adapterDegree = adapterDegree;
    }

    public Double getKpCoverage() {
        return kpCoverage;
    }

    public void setKpCoverage(Double kpCoverage) {
        this.kpCoverage = kpCoverage;
    }
}
